package com.heima.admin.job;

import com.heima.admin.feign.WemediaFeign;
import com.heima.admin.service.WemediaNewsAutoScanService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Title: TODO
 * @Description: TODO
 * @author: 丁丁
 * @date: 2021/3/21
 * @version:
 */
@Component
@Log4j2
public class WeMediaNewsAutoScanJob {
    
    @Autowired
    private WemediaFeign wemediaFeign;

    @Autowired
    private WemediaNewsAutoScanService wemediaNewsAutoScanService;
    
    @XxlJob("wemediAutoScanJob")
    public ReturnT newsAutoScanJob(String param){
        log.info("自媒体文章审核调度任务开始执行....");
        // 查询审核通过由待发布的文章
        List<Integer> releaseLists = wemediaFeign.findRelease();
        if (releaseLists!=null&&!releaseLists.isEmpty()){
            for (Integer id : releaseLists) {
                wemediaNewsAutoScanService.autoScanByMediaNewsId(id);
            }
        }
        log.info("自媒体文章审核调度任务执行结束....");
        return ReturnT.SUCCESS;
    }
}
